package vn.bang.dao.impl;

import java.util.List;

import vn.bang.dao.UserDAO;
import vn.bang.entity.UserDTO;

import com.googlecode.genericdao.search.Search;

public class UserDAOImpl extends AbstractBaseDAOImpl<UserDTO, Long> implements UserDAO {

	public UserDTO findActiveByUsername(String username) {
		Search search = new Search(UserDTO.class);
		search.setFirstResult(0);
		search.setMaxResults(Integer.MAX_VALUE);
		search.addFilterEqual("active", Boolean.TRUE);
		search.addFilterEqual("username", username);
		
		List<UserDTO> users = this.search(search);
		if (null == users || users.isEmpty()) {
			return null;
		}
		return users.get(0);
	}
}
